﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Lokad.Monitoring.Persistence.Entities.Report>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Monitoring Reports
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <table>
        <tr>
            <th>
                Report Name
            </th>
            <th>
                Status
            </th>
            <th>
                Last Refresh
            </th>
            <th>
                Endpoints
            </th>
            <th></th>
        </tr>

    <% foreach (var item in Model) { %>
        <tr>
            <td style="font-size:150%">
                <%= Html.ActionLink(item.Id, "Report", new { id = item.Id })%>
            </td>
            
            <%= item.IsFault ? "<td class=\"fault\">fault</td>" : "<td class=\"success\">OK</td>" %>
            
            <td>
                <%= !(new DateTime(1901, 1, 1)).Equals(item.LastRefreshed) ? 
                    Math.Round(DateTime.UtcNow.Subtract(item.LastRefreshed).TotalMinutes, 1) + "min ago" :
                    "never refreshed" %>
            </td>

            <td>
                <%= Html.Encode(item.Endpoints) %>
            </td>
            <td>
                <%= Html.ActionLink("Edit", "Edit", new { id=item.Id }) %> |
                <%= Html.ActionLink("Force Refresh", "ForceRefresh", new { id=item.Id }) %>
            </td>
        </tr>
    <% } %>
    </table>

    <p>
        <%= Html.ActionLink("Create a new report", "Create") %>
    </p>

    <p>
        Deleting a report: /Home/Delete/<em>reportName</em><br/>
        Monitor from a Google Gadget: <a href="http://www.google.com/ig/adde?moduleurl=http://lokad-monitoring.googlecode.com/svn/trunk/Resource/Misc/rsm-google-gadget.xml">add gadget</a> with <a href="/status.json">endpoint</a>.
    </p>

</asp:Content>

